package com.bush.mall.ware.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.ware.entity.PurchaseEntity;
import com.bush.mall.ware.service.PurchaseService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 采购信息
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("purchase")
@Api(tags = "采购信息管理" )
public class PurchaseController {

    @Resource(name= PurchaseService.BEAN_ID)
    private PurchaseService purchaseService;

    /**
     * 分页查询采购信息列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询采购信息列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return purchaseService.queryForPage(current,size);
    }

    /**
     * 保存采购信息表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存采购信息表单")
    @PostMapping
    public Result savePurchase(@RequestBody PurchaseEntity purchase){
        return purchaseService.savePurchase(purchase);
    }

    /**
     * 修改采购信息表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改采购信息表单")
    @PutMapping
    public Result updatePurchase(@RequestBody PurchaseEntity purchase){
        return purchaseService.updatePurchase(purchase);
    }

    /**
     * 通过指定id删除采购信息
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除采购信息")
    @DeleteMapping
    public Result deletePurchase(Long id){
        return purchaseService.deletePurchase(id);
    }

}
